<template>
  <div>
    <a-comment>
      <a slot="author">{{detail.user_name}}</a>
      <a-avatar :src="detail.img" alt="Han Solo" slot="avatar" />
      <div slot="content">
        <p>年龄：{{detail.age}}</p>
        <p>user_id：{{detail.user_id}}</p>
        <p>{{detail.description}}</p>
      </div>
      <a-tooltip slot="datetime" :title="detail.create_time">
        <span>{{detail.create_time}}</span>
      </a-tooltip>
    </a-comment>
  </div>
</template>

<script>
export default {
  validate({params}){
    return /^[0-9a-zA-Z_]{1,}$/.test(params.id)
  },
  data() {
    return {
      detail: {}
    };
  },
  created() {
    console.log("id", this.$route.params.id);
    fetch("/api/detail/" + this.$route.params.id)
      .then(res => res.json())
      .then(res => {
        if (res.status) {
          this.detail = res.data[0];
        } else this.$message.error(res);
      });
  }
};
</script>

<style>
</style>